home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 March / CMCD0305.ISO / Software / Shareware / Utilitare / emu / Emu8086_Setup_307c.exe / {app} / Samples / pages.asm < prev    next >
Assembly Source File  |  2002-08-02  |  1KB  |  93 lines

  1. ; This example demonstrates
  2. ; the use of pages (double-buffering).
  3. ; This program uses first 4 pages of
  4. ; video memory by setting some data
  5. ; on them, and waits for any key,
  6. ; pressing any key will show all
  7. ; pages one after another.
  8.  
  9. #make_COM#
  10.  
  11. ORG 100h
  12.  
  13. ; set video mode:
  14. ; Text mode 40x25, 16 colors, 8 pages
  15. MOV     AH, 0
  16. MOV     AL, 0
  17. INT     10h
  18.  
  19. ; ======== print chars on different pages:
  20.  
  21. MOV AL, '0' ; char to print.
  22. MOV BH, 0 ; page number.
  23.  
  24. do_print:
  25.  
  26. MOV BL, 01001111b ; attributes.
  27. MOV CX, 1018   ; number of chars to write.
  28. MOV AH, 09h ; write char function.
  29. INT 10h
  30.  
  31. INC AL  ; next char.
  32. INC BH  ; next page.
  33.  
  34. CMP AL, '4'
  35. JB  do_print
  36.  
  37.  
  38. ; ===== modify pages by writing directly
  39. ;       to video memory:
  40.  
  41. PUSH    DS
  42.  
  43. MOV AX, 0B800h
  44. MOV DS, AX
  45.  
  46. ; First byte is a color attribute
  47. ; (0F2h = white background, green char),
  48. ; second byte is an ASCII code
  49. ; (41h = 'A', 42h = 'B', 43h = 'C'...)
  50.  
  51. MOV DI, 0           ; page 0.
  52. MOV w.[DI], 0F241h
  53.  
  54. ADD DI, 4096        ; page 1.
  55. MOV w.[DI], 0F242h
  56.  
  57. ADD DI, 4096        ; page 2.
  58. MOV w.[DI], 0F243h
  59.  
  60. ADD DI, 4096        ; page 3.
  61. MOV w.[DI], 0F244h
  62.  
  63. POP DS
  64.  
  65. ; ======= show pages one after another:
  66.  
  67. MOV  AL, 0   ; page number
  68.  
  69. show_next_page:
  70.  
  71. MOV  AH, 05h ; change page function.
  72. INT  10h
  73.  
  74. PUSH AX
  75. ; wait for any key:
  76. XOR  AX, AX
  77. INT  16h
  78. POP  AX
  79.  
  80. INC  AL
  81.  
  82. CMP  AL, 4
  83. JB   show_next_page
  84.  
  85.  
  86.  
  87.  
  88. RET ; return to OS.
  89.  
  90. ;==============================
  91.  
  92. END
  93.